Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow construction of empty Zonemaster::LDNS::RRList objects #209

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

marc-vanderwal
Copy link
Contributor

Purpose

This PR addresses a design oversight in the constructor for Zonemaster::LDNS::RRList objects. It was for now assumed that it would always be used to construct nonempty RRList objects, but a PR in Zonemaster-Engine elicited the need for exactly that use case.

Context

Follow-up to #203; review of zonemaster/zonemaster-engine#1383.

Changes

Allow calling Zonemaster::LDNS::RRList::new() with either no argument or an empty arrayref.

How to test this PR

Unit tests were added, and should therefore pass.

@marc-vanderwal marc-vanderwal added this to the v2024.2 milestone Oct 16, 2024
@marc-vanderwal marc-vanderwal changed the title Bugfix/allow empty rrlists Allow construction of empty Zonemaster::LDNS::RRList objects Oct 16, 2024
@marc-vanderwal
Copy link
Contributor Author

CI failures seem to be addressed in #208.

tgreenx
tgreenx previously approved these changes Oct 16, 2024
The change in zonemaster#203 introduced a new() function in the
Zonemaster::LDNS::RRList module.

However, calling new() with a ref to an empty array as paramater caused
the code to croak with the error message "List is empty". However, there
are situations where it may be desirable to construct such an empty
RRList.

This commit ensures that Zonemaster::LDNS::RRList->new([]) works as
intended.
Modify the XS code so that Zonemaster::LDNS::RRList::new() can be called
with zero arguments, which is equivalent to passing it an empty arrayref.
@marc-vanderwal
Copy link
Contributor Author

I’ve rebased on latest develop so that CI works, and included another minor change in rrlist.t.

mattias-p
mattias-p previously approved these changes Oct 18, 2024
Copy link
Member

@mattias-p mattias-p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I like the tests you added. I thought of a few additional ones, but maybe that's overkill.

  • Checking the return values of string, count and get for $empty_b.
  • Checking eq and ne with the $empty_a on the right side.

Let’s make sure that new() and new([]) have the same semantics, and that
the eq operator works correctly in both ways with these empty lists.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants